package com.naire.modul.projecplan.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;

import com.naire.modul.projecplan.service.ProjecTreeSearchService;
import com.naire.modul.projecplan.service.ProjecplanDeleteService;
import com.naire.modul.projecplan.service.ProjecplanEditorService;
import com.naire.modul.projecplan.service.ProjecplanFindService;
import com.naire.modul.projecplan.service.ProjecplanSearchService;
import com.naire.modul.projecplan.vo.ProjecplanVo;

public class ProjecplanAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private ProjecplanVo bean = new ProjecplanVo();
	private List<ProjecplanVo> list = new ArrayList<ProjecplanVo>();
	private Integer periods_id;

	public void jsonTree() throws Exception {
		ProjecTreeSearchService service = new ProjecTreeSearchService();
		service.invoke();
		json(service.getList());
	}

	public String search() throws Exception {
		ProjecplanSearchService service = new ProjecplanSearchService();
		service.setPageBean(pageBean);
		service.setPeriods_id(periods_id);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String editor() throws Exception {
		ProjecplanEditorService service = new ProjecplanEditorService();
		service.setBean(bean);
		service.setPeriods_id(periods_id);
		service.invoke();
		return SUCCESS;
	}

	public String find() throws Exception {
		if (bean.getPlan_id() != null) {
			ProjecplanFindService service = new ProjecplanFindService();
			service.setId(bean.getPlan_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}

	public String delete() throws Exception {
		ProjecplanDeleteService service = new ProjecplanDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public ProjecplanVo getBean() {
		return bean;
	}

	public void setBean(ProjecplanVo bean) {
		this.bean = bean;
	}

	public List<ProjecplanVo> getList() {
		return list;
	}

	public void setList(List<ProjecplanVo> list) {
		this.list = list;
	}

	public Integer getPeriods_id() {
		return periods_id;
	}

	public void setPeriods_id(Integer periods_id) {
		this.periods_id = periods_id;
	}
}
